<html>
<head><meta charset="utf-8"><title>coherence for function bodies · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html">coherence for function bodies</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175790942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/175790942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#175790942">(Sep 16 2019 at 07:58)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span>: <span class="user-mention" data-user-id="199355">@vlad</span> and I were discussing the problem of "impls inside functions leak outside". Do you think it makes sense to submit some RFC on the topic, just to start things moving? I think the delta which we want to apply (modulo backwards compat) is:</p>
<ul>
<li>tweak visibility rules for inherent methods such that they can't be pub, and can't be visible outside of block </li>
<li>forbid <code>#[macro_export]</code> for local macros</li>
<li>(the trickiest bit, and wg-traits turf, idea of <span class="user-mention" data-user-id="200750">@Vlad</span> ) treat bodies of functions as downstream crates from POV of coherence, such that impls inside bodies are allowed, but only if they can't inflerence type inference outside. </li>
</ul>
<p>It seems like we don't have capacity to work on this right now, but perhaps it makes sense to submit an RFC just to keep the problem documented?</p>



<a name="175793845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/175793845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#175793845">(Sep 16 2019 at 08:44)</a>:</h4>
<p>It would be enough though to deprecate / lint against this with a message saying "don't do this, or it won't work with IDEs", right?</p>



<a name="175793886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/175793886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#175793886">(Sep 16 2019 at 08:45)</a>:</h4>
<p>Right, and <code>#[allow(leaking_impls)]</code> on the function would cause IDE to look inside</p>



<a name="175793941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/175793941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#175793941">(Sep 16 2019 at 08:46)</a>:</h4>
<p>Like, the act of silencing the lint makes it non-problematic, which is a fun property :)</p>



<a name="175794211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/175794211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#175794211">(Sep 16 2019 at 08:50)</a>:</h4>
<p>unless you silence it in the whole crate ;)</p>



<a name="176227706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176227706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176227706">(Sep 20 2019 at 20:27)</a>:</h4>
<p>I have been thinking about this a bit as well. I don't think I'd submit an <em>RFC</em> -- but it'd be nice to have some place to track it as a "future idea".</p>



<a name="176228004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228004">(Sep 20 2019 at 20:31)</a>:</h4>
<p>What that place would be?</p>



<a name="176228259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228259">(Sep 20 2019 at 20:35)</a>:</h4>
<p>There is no good place right now I don't think</p>



<a name="176228270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228270">(Sep 20 2019 at 20:35)</a>:</h4>
<p>But I dont' like using open RFCs for it, I know tha t:)</p>



<a name="176228287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228287">(Sep 20 2019 at 20:35)</a>:</h4>
<p>I guess in theory issues on rust-lang/rfcs is the official place</p>



<a name="176228303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228303">(Sep 20 2019 at 20:36)</a>:</h4>
<p>(I have wanted however to create something i the <a href="https://github.com/rust-lang/lang-team/" target="_blank" title="https://github.com/rust-lang/lang-team/">lang-team</a> repository)</p>



<a name="176228339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228339">(Sep 20 2019 at 20:36)</a>:</h4>
<p>but I didn't yet :)</p>



<a name="176228418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/coherence%20for%20function%20bodies/near/176228418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/coherence.20for.20function.20bodies.html#176228418">(Sep 20 2019 at 20:37)</a>:</h4>
<p>FWIW, I feel like my and <span class="user-mention silent" data-user-id="200750">Vlad</span> 's heads provide enough redundancy here, so no additional storage is required. Logistically, it maybe makes sense to thing about this once chalk is fully in production?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>